package com.tdb.mapper;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/4/6  14:43
 * 描述:
 */
@Component
public class TestService {

    @Autowired
    private TestMapper testMapper;

    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED,timeout = 20)
    public int testMapper1() throws InterruptedException {
        int i = testMapper.updateOne(111);
        Thread.sleep(10000);
        int i2 = testMapper.updateOne2(201);
        return i;
    }

    @Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRED,timeout = 20)
    public int testMapper2(){

        int i = testMapper.updateOne2(201);
        int i2 = testMapper.updateOne(111);

        return i;
    }

}
